#ifndef PSHIP_H
#define PSHIP_H

#include <physics/pobject.h>

/**
  * Ship.
  */
class PShip : public PObject
{
public:
    PShip(PWorld *world, QString name);

    /**
      * Is ship accelerating.
      */
    bool isAccelerating() const;

    /**
      * Is ship turning right.
      */
    bool isRight() const;

    /**
      * Is ship turning left.
      */
    bool isLeft() const;

    /**
      * Is ship firing.
      */
    bool isFire() const;

    /**
      * Returns angle.
      */
    double getAlpha() const;


    void setAccelerate(bool b);
    void setRight(bool b);
    void setLeft(bool b);
    void setFire(bool b);

    void setAlpha(double alpha);

    void turnLeft();
    void turnRight();

    double getEngine() const;
    double getBulletSpeed() const;
    double getEnergyForBullet() const;

    double getEnergy() const;
    void setEnergy(double energy);
    double getMaxEnergy() const;
    void setMaxEnergy(double maxEnergy);
    double getEnergyForEngine() const;
    void incEnergy(double energy);
    void decEnergy(double energy);

    void serialize(QDomDocument *doc, QDomElement *e) const;

    static PShip *deserialize(QDomNode *e, PWorld *parent);

private:
    bool acceleration;
    bool right;
    bool left;
    bool shoot;

    double myAlpha;
    double myDAlpha;

    double myEngine;
    double myBulletSpeed;
    double myEnergyForBullet;
    double myEnergyForEngine;

    double myEnergy;
    double myMaxEnergy;
};

#endif // PSHIP_H
